/**
 * Created by GeYang on 2018/12/06.
 */
import config from '../../assets/js/config'
import $ from 'jquery'

const NODE_ENV = config.NODE_ENV;
const WEB_URL = config.WEB_URL;
const DEV_URL = config.DEV_URL;
const PROD_URL = config.PROD_URL;

export const getWebUrl = () => {
  if (process.env.NODE_ENV === 'production') {
    return WEB_URL
  } else {
    return DEV_URL
  }
};

export const showImg = (url) => {
  let url_prefix = '';
  if (process.env.NODE_ENV === 'production') {
    url_prefix = PROD_URL
  } else {
    url_prefix = DEV_URL
  }
  return url_prefix + '/public/static' + url;
};

export const getApiUrl = (api) => {
  // return '/public/?service=' + api
  if (process.env.NODE_ENV === 'production') {
    // return PROD_URL + '/?s=' + api
    return DEV_URL + api;
  } else {
    return DEV_URL + api;
  }
};

export const getStore = (name, parse = false) => {
  if (!name) return false;
  if (parse) {
    return JSON.parse(window.localStorage.getItem(name))
  }
  return window.localStorage.getItem(name)
};
